﻿using Sx.Mall.WebContract;
using Sx.Mall.WebContract.Dto;
using Mall.Infrastructure.Container;
using Mall.Infrastructure.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Sx.Mall.Web.Filter;

namespace Sx.Mall.Web.Controllers
{
    public class ProductBigTypeManageController : Controller
    {
        private static InterfaceContainer app = AppDomain.CurrentDomain.GetContainer();

        private IProductBigtypeService service;

        public ProductBigTypeManageController()
        {
            service = app.GetSerivce<IProductBigtypeService>();

        }

        /// <summary>
        /// 获取产品大分类列表
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="page"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public JsonResult GetProductBigTypelist(ProductBigtypeDto dto,int page,int rows)
        {
            dto.Page = new Page();
            dto.Page.PageSize = rows;
            dto.Page.CurrentPage = page;
            var result = service.GetList(dto);
            return Json(result);
        }

        /// <summary>
        ///添加产品大分类
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult AddProductBigType(ProductBigtypeDto dto) 
        {
            dto.CreateID = LoginHelper.GetUser().UserId;
            dto.CreateName = LoginHelper.GetUser().UserName;
            dto.CreateTime = DateTime.Now;
            var result = service.Add(dto);
            return Json(result);
        }
    }
}
